package com.xuanyue.db.xuan.core.table.groupby;

import java.util.Map;

public class TwinNumberTail8GroupKey implements IGroupKey {

	@Override
	public Integer key(Map<String, Object> vs) {
		Object o = vs.get("phone");
		if(o==null) {
			return -1;
		}else {
			String ph = o.toString();
			char c;
			int r=0;
			for(int i=3,p=28;i<11;i++) {
				c = ph.charAt(i);
				switch(c) {
					case '0':
						break;
					case '1':
						r|= (1<<p);
						break;
					case '2':
						r|= (2<<p);
						break;
					case '3':
						r|= (3<<p);
						break;
					case '4':
						r|= (4<<p);
						break;
					case '5':
						r|= (5<<p);
						break;
					case '6':
						r|= (6<<p);
						break;
					case '7':
						r|= (7<<p);
						break;
					case '8':
						r|= (8<<p);
						break;
					case '9':
						r|= (9<<p);
						break;
					case '*':
						r|= (15<<p);
						break;
				}
				p-=4;
			}
			
			return r;
		}
	}

}
